package com.example.run.teacherhelper.Fragments;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import com.example.run.teacherhelper.Activities.DianMingActivity;
import com.example.run.teacherhelper.Adapters.ClassesAdapter;
import com.example.run.teacherhelper.R;
import com.example.run.teacherhelper.module.MyClass;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by run on 2015/10/16.
 */
public class Day_Class_info_Fragment extends Fragment {
    private ListView mListView;
    private List<MyClass> mClassess=new ArrayList<MyClass>();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.day_class_info,null);
        mListView=(ListView)view.findViewById(R.id.my_classes);
        /*Task task= (Task) new Task().execute();//异步请求信息*/
        if(mClassess.size()==0) {
            for (int i = 0; i < 4; i++) {
                mClassess.add(new MyClass("当前课程", "   ", "    "));
            }
        }
//       数据绑定
        ClassesAdapter adapter=new ClassesAdapter(getActivity().getApplicationContext(),R.layout.class_item_view,
                mClassess);
        mListView.setAdapter(adapter);
        setItemClick(mListView);
        return view;
    }

//    异步加载信息
    /*class Task extends AsyncTask<Void, Void, Map>{
        @Override
        protected Map doInBackground(Void... params) {
            return null;
        }
    }*/
    public void setItemClick(ListView mlistView){
        mlistView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                startActivity(new Intent(getActivity(), DianMingActivity.class));
            }
        });
    }

}
